<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="generator" content="macvim" />
<meta name="author" content="http://fisherhe.com (heqiang.org@gmail.com)" />
<title>ajax-demo</title>
<script src="js/jquery.js" type="text/javascript"></script>
<style type="text/css" media="screen">
body {
	line-height:1.5;
}
#testdiv a {
	margin:0 10px 0 0;
}
</style>
</head>
<body>
<p><a href="#" id="aaa">拉取店铺自定义分类</a> <a href="#" id="bbb">拉取商品基本信息</a> <a href="#" id="ccc">拉取商品描述信息</a></p>
<div id="testdiv"></div>
<script type="text/javascript">
$('#aaa').click(function(){
	$.ajax({
		url:'http://localhost/~fisherhe/fpbs/trunk/paipai/get-api.php?pureData=1&api=/shop/getShopCategoryList.xhtml&sellerUin=855000298',
		dataType:'json',
		cache:false,
		success:function(data) {
			//alert("ok");
			console.log('ok');
			console.log(this);
			$.each(data.shopCategoryList.shopCategory,function(i){
				$shopCategory = this;
				//console.log(this);
				//$shopCategory = $(this);
				var links = '<a href="' + $shopCategory.categoryLink + '">' + $shopCategory.desc + '</a>';
				//var ulist = $("<ul></ul>").append(links);
				$("#testdiv").append(links);
				console.log(links);
			});
		},
		error:function() {
			//alert("error");
			console.log('error');
		}
	});
});

$('#bbb').click(function(){
	$.ajax({
		url:'http://localhost/~fisherhe/fpbs/trunk/paipai/get-api.php?pureData=1&api=/item/getItem.xhtml&itemCode=1A56F63200000000001A3B5608291574',
		dataType:'json',
		cache:false,
		success:function(data) {
			var $name = '<h1>'+ data.itemName + '</h1>';
			var $price = '<ul><li>价格：'+ data.itemPrice +'</li>';
			var $regionInfo = '<li>所在地：'+ data.regionInfo +'</li>';
			var $itempic = '<li><img src="'+ data.picLink +'" /></li>';
			$("#testdiv").append($name + $price + $regionInfo + $itempic + '</ul>');
			return false;
			console.log(data.itemName);

			console.log("ok");
		},
		error:function(){
			console.log('error');
		}
	});
});

$('#ccc').click(function(){
	$.ajax({
		url:'get-api.php?pureData=1&api=/item/getItemDetailInfo.xhtml&itemCode=1A56F63200000000001A3B5608291574',
		dataType:'json',
		cache:false,
		success:function(data) {
			$('#testdiv').append(data.detailInfo);
			console.log("ok");
			console.log(data.detailInfo);
		},
		error:function(){
			console.log('error');
		}
	});
});
</script>
</body>
</html>
